//
//  CZStatus.swift
//  Swift -- 微博
//
//  Created by sks on 16/6/28.
//  Copyright © 2016年 mohaha. All rights reserved.
//

import UIKit

class CZStatus: NSObject {
    
    /// 微博创建时间
    var created_at: String?
    /// 微博ID
    var id: Int64 = 0
    /// 微博信息内容
    var text: String?
    /// 微博来源
    var source: String?
    
    // 用户信息
    var user: CZUser?
    
    //转发微博
    var retweet_stauts : CZStatus?
    
    
    // KVC构造函数
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            
            guard let v = value as? [String : AnyObject] else{
            
              return
            }
            let u = CZUser(dict: v)
            user = u
            
        }else if key == "retweeted_status"{
        
            guard let v = value as? [String : AnyObject] else{
               return
            }
            
            let s = CZUser(dict: v)
            
            user = s
            
        }else{
        
          self.setValue(value, forKey: key)
        }
    }

}
